home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form FindOrClose
- Caption = "Form2"
- ClientHeight = 2520
- ClientLeft = 1095
- ClientTop = 1485
- ClientWidth = 6045
- Height = 2925
- Left = 1035
- LinkTopic = "Form2"
- ScaleHeight = 2520
- ScaleWidth = 6045
- Top = 1140
- Width = 6165
- Begin CommandButton cmd_CloseIt
- Caption = "Close It"
- Height = 435
- Left = 2400
- TabIndex = 6
- Top = 1920
- Width = 1095
- End
- Begin CommandButton Command1
- Caption = "Ok"
- Height = 435
- Left = 4680
- TabIndex = 5
- Top = 1920
- Width = 1155
- End
- Begin TextBox Txt_Windows
- Height = 315
- Index = 1
- Left = 2340
- TabIndex = 3
- Top = 480
- Width = 3075
- End
- Begin TextBox Txt_Windows
- Height = 315
- Index = 0
- Left = 2340
- TabIndex = 1
- Top = 120
- Width = 3075
- End
- Begin Label lab_handlenum
- Caption = "Window Handle is:"
- Height = 195
- Left = 1560
- TabIndex = 4
- Top = 960
- Width = 3375
- End
- Begin Label Label2
- Alignment = 1 'Right Justify
- Caption = "Window Class:"
- Height = 195
- Left = 240
- TabIndex = 2
- Top = 540
- Width = 2055
- End
- Begin Label Label1
- Alignment = 1 'Right Justify
- Caption = "Window Caption:"
- Height = 195
- Left = 240
- TabIndex = 0
- Top = 180
- Width = 2055
- End
- Option Explicit
- Dim CurrentHnd%
- Sub cmd_CloseIt_Click ()
- Dim dl&
- Dim hnd%
- hnd% = CurrentHnd%
- If hnd% <> 0 Then dl& = PostMessageBynum(hnd%, WM_CLOSE, 0, 0&)
- End Sub
- Sub Command1_Click ()
- Unload Me
- End Sub
- Function FindTheWindow% ()
- Dim hnd%
- If txt_Windows(0).Text <> "" And txt_Windows(1).Text <> "" Then
- FindTheWindow% = FindWindowByString(txt_Windows(1).Text, txt_Windows(0).Text)
- Exit Function
- End If
- If txt_Windows(0).Text <> "" Then
- FindTheWindow% = FindWindowByCaption(0&, txt_Windows(0).Text)
- Exit Function
- End If
- If txt_Windows(1).Text <> "" Then
- FindTheWindow% = FindWindowByClass(txt_Windows(1).Text, 0&)
- Exit Function
- End If
- FindTheWindow% = 0
- End Function
- Sub Form_Load ()
- Select Case LastCommand%
- Case 2
- Me.Caption = "Find the Window of Another App"
- cmd_Closeit.Visible = 0
- Case 3
- Me.Caption = "Close Another App"
- End Select
- End Sub
- Sub Txt_Windows_Change (Index As Integer)
- Dim hnd%
- hnd% = FindTheWindow()
- CurrentHnd% = hnd%
- lab_handlenum = "Window Handle is: " & Hex$(hnd%)
- End Sub
-